const http=require('http')
const serve=http.createServer()
serve.on('request',(req,res)=>{
    
    const url=req.url
    let content='<h1>404 not found<h1>'
    if(url=='/'||url=='/index'){
        content='<h1>首页</h1>'
    }else if(url=='/about'){
        content='<h1>关于页面</h1>'
    }
    const method=req.method
    const str=`你的请求地址为${url},你的请求方法为${method}`
    console.log(str)
// 中文乱码只会在客户显示端出现，所以在res.end方法调用前设置
    res.setHeader('Content-Type','text/html;charset=utf-8')
    res.end(content)
    // res.end(str)
   

})
serve.listen(70,()=>{
    const str1=`"http serve is runing at http://127.0.0.1:70"`
    console.log(str1)
})